package com.andox.fn.inf.rpc.rest.common;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.andox.fn.inf.rpc.rest.RpcRequest;
import com.andox.fn.inf.rpc.rest.RpcResponse;
import com.andox.fn.inf.rpc.rest.serializer.Serializer;

/**   
 * @ClassName:   HeartbeatHandler   
 * @Description: TODO  
 * @author:      Andox
 * @date:        2019年8月1日 上午11:22:52   
 *     
 */
public class HeartbeatHandler implements RequestHandler{
	public final static String PING = "ping";
	public final static String PONG = "pong";
	
	private Serializer serializer;
	
	@Override
	public int supportType() {
		return RequestType.HEART_BEAT;
	}

	@Override
	public RpcResponse handle(RpcRequest ar, HttpServletRequest httpServletRequest,
			HttpServletResponse httpServletResponse) {
		return RpcResponse.success(ar.getOpaque(), serializer.serializeAsString(PONG));
	}
}
